//
//  GKZYChatListController.m
//  GKZYAid
//
//  Created by lanou3g on 16/3/8.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYChatListController.h"
#import "GKZYChatDetailController.h"
@interface GKZYChatListController ()<RCIMUserInfoDataSource>

@end

@implementation GKZYChatListController

- (id)init
{
    self = [super init];
    if (self) {
        
        //那些会话能显示:
        [self setDisplayConversationTypes:@[@(ConversationType_PRIVATE),@(ConversationType_GROUP),@(ConversationType_DISCUSSION)]];
        
        //聚合显示会话类型://私聊:
        [self setCollectionConversationType:@[@(ConversationType_GROUP),@(ConversationType_DISCUSSION)]];
        
    }
    return self;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    //隐藏tabBar
    self.tabBarController.tabBar.hidden = YES;
    self.title = @"聊天页面";

    //cell的背景颜色:
    //self.cellBackgroundColor = [UIColor cyanColor];
    [[RCIM sharedRCIM] setUserInfoDataSource:self];
    
}

//代理方法:
- (void)getUserInfoWithUserId:(NSString *)userId
                   completion:(void (^)(RCUserInfo *userInfo))completion{
    
    RCUserInfo *userInfo = [[RCUserInfo alloc]init];
    
    userInfo.userId = userId;
    userInfo.name = userId;
    userInfo.portraitUri = @"http://www.deskcar.com/desktop/else/2012919110429/3.jpg";
    
    return completion(userInfo);

}

//点击会话列表中Cell的回调
- (void)onSelectedTableRow:(RCConversationModelType)conversationModelType
         conversationModel:(RCConversationModel *)model
               atIndexPath:(NSIndexPath *)indexPath{
    //聚合显示:
    if (conversationModelType == RC_CONVERSATION_MODEL_TYPE_COLLECTION) {
        
        GKZYChatListController *temp = [[GKZYChatListController alloc]init];
        NSArray *array = [NSArray arrayWithObject:[NSNumber numberWithInt:model.conversationType]];
        [temp setDisplayConversationTypes:array];
        [temp setCollectionConversationType:nil];
        temp.isEnteredToCollectionViewController = YES;
        [self.navigationController pushViewController:temp animated:YES];
        
        //私聊页面
    }else if (model.conversationType == ConversationType_PRIVATE){
       
        GKZYChatDetailController *chatVC = [[GKZYChatDetailController alloc]init];
        
        //类型:
        chatVC.conversationType = model.conversationType;
        chatVC.targetId = model.targetId;
        chatVC.titleName = model.targetId;
        [self.navigationController pushViewController:chatVC animated:YES];
        
        
    }
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
